#include "stdafx.h"
#include "CppUnitTest.h"
#include "bounded_vector.h"

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace UnitTest1
{		
	TEST_CLASS(UnitTest1)
	{
	public:
		
		TEST_METHOD(TestIsEmpty)
		{
			bounded_vector bv;
			Assert::AreEqual(true, bv.is_empty());
		}

		TEST_METHOD(TestConstructor)
		{
			bounded_vector bv1('a', 'z');
			Assert::AreEqual(true, bv1.GetSize() == 26);
			bounded_vector bv2('a', 'c');
			Assert::AreEqual(true, bv2.GetSize() == 3);
		}

		TEST_METHOD(TestCopyConstructor)
		{
			bounded_vector bv1('a', 'z');
			bounded_vector bv2(bv1);
			Assert::AreEqual(true, bv2.GetSize() == 26);
		}

		TEST_METHOD(TestCopyAssigmentOperator)
		{
			bounded_vector bv1('a', 'z');
			bounded_vector bv2;
			bv2 = bv1;
			Assert::AreEqual(true, bv2.GetSize() == 26);
		}

		TEST_METHOD(TestTotalSum)
		{
			bounded_vector bv('a', 'z');
			bv['b'] = 10;
			bv['g'] = 26;
			Assert::AreEqual(36, bv.total_sum());
		}

		TEST_METHOD(TestAdd)
		{
			bounded_vector bv1('a', 'z');
			bounded_vector bv2('a', 'd');
			bv1['a'] = 3;
			bv1['c'] = 5;
			bv2['a'] = 3;
			bv2['d'] = 5;
			bounded_vector bv3 = (bv1 + bv2);
			Assert::AreEqual(16, bv3.total_sum());
		}

		TEST_METHOD(TestIterator)
		{
			bounded_vector bv('a', 'c');
			bv['a'] = 5;
			bv['b'] = 10;
			bv['c'] = 15;

			int tempsum = 0;
			for (auto it = bv.begin(); it != bv.end(); it++)
			{
				tempsum += *it;
			}
			Assert::AreEqual(true, bv.total_sum() == tempsum);
		}

	};
}